package com.aeye.mbr.upms.server.controller.manage.base;

import com.aeye.mbr.common.base.BaseController;
import com.aeye.mbr.common.result.BootstrapTableParams;
import com.aeye.mbr.upms.dao.model.UpmsDict;
import com.aeye.mbr.upms.rpc.api.DictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>Description: </p>
 *
 * @author zhouchuanbo
 * @version 1.0
 * @date 2018/3/19 0019
 */
@Controller
@Api(value = "数据字典", description = "数据字典")
@RequestMapping("/manage/base/dict")
public class DictController extends BaseController {

    @Autowired
    private DictService dictService;

    @ApiOperation(value = "数据字典首页")
    @RequiresPermissions("upms:dict:read")
    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public String index() {
        return "/manage/base/dict/index.jsp";
    }

    @ApiOperation(value = "数据字典列表")
    @RequiresPermissions("upms:dict:read")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public Object list(BootstrapTableParams params, String search, String fieldName, String fieldComment) {
        System.out.println(search);
        return dictService.selectDictListByParams(params, fieldName, fieldComment);
    }

    @ApiOperation(value = "数据字典")
    @RequestMapping(value = "/dictSelect", method = RequestMethod.GET)
    @ResponseBody
    public Object list2(String appFieldName) {
        UpmsDict dict = new UpmsDict();
        dict.setAppFieldName(appFieldName);
        List<UpmsDict> list = dictService.selectDictList(dict);
        return list;
    }
}
